package com.study.crypto.basic.kafka.producer.controller;

import com.study.crypto.basic.kafka.producer.service.KafkaMessageSendService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Songjin
 * @since 2021-09-26 15:54
 */
@RestController
public class KafkaMessageSendController {

    @Autowired
    private KafkaMessageSendService kafkaMessageSendService;
    
    @PostMapping("/sendMessage")
    public String send(@RequestParam String message){
        try {
            kafkaMessageSendService.send(message);
        } catch (Exception e) {
            return "send failed.";
        }
        return message;
    }
}